classic_battlefield_moddingfandomcom-20200214-history
BF 2 Modding Tutorial 6 Build Car Max
BF 2 Modding Tutorial 6 Build Car Max Battlefield 2 Modding Tutorial 6 Building the Car - Max Last update – 8/19/05 In this lesson we will create a basic car. No guns or anything yet, just a basic vehicle to zip around in. Note: I’ve provided example scene files that you should use to follow along. I will be writing this tutorial assuming that you are using these examples. Feel free to try creating your own files if you like, but pay very close attention to the instructions, especially the naming conventions. If you are having problems, you may wish to open one of the existing examples and compare it to the file you are working on. There is a file called “My_Car.max” that is the finished version of this tutorial. If you wish to save your work as you proceed, don’t overwrite this file because you may want it later. Save your work with a different name, such as My_Car_Test.max” or something similar. Set-Up: Locate the “Tutorial Files” folder included with this tutorial and open it. Read the file “InstallReadMe” for instructions on installing the necessary files. Modeling: Before we can do anything else, we of course have to model the car. There are many optional pieces you can add to a vehicle, such as a cockpit and steering wheel, but for this lesson we’re just going to deal with the basics. The Main LOD: This is the main visible mesh of your vehicle. It should contain the most detail, including such things as headlights, runningboards, exhaust pipes, and so on. This is the model that will be seen when a player gets close to it. Image File: My_Car01Max.jpg> Notice that I’ve added a few small details, such as headlights and fenders. I’ve also spent a fair amount of polygons on the wheels. In this case they are quite large (almost 2 meters tall), so more polygons were necessary to keep the edges round. You may be able to get away with less polygons on smaller wheels, but keep in mind that nothing makes a model look worse than wheels that aren’t “round”. Spend a few extra polygons here and save somewhere else where detail isn’t as critical if you have to. I’ve also added some detail to the center of the wheels where the axle is. You can put some detail here, but a lot can be done with the texture normal map later to add things like bolts. You may also be able to get away with using the transparency channel for things like cutouts in Mag wheels and so on. Like all game models, it’s always a tradeoff between detail and engine rendering load, so you’ll have to experiment, but keep in mind that this is the highest LOD that will only be seen when a player is close to it. You will make lower detailed versions later on. Also notice that I am modeling the wheels at the same time as the rest of the vehicle. In previous versions of Battlefield, you would model each piece separately and then assemble them in the .con files. In BF2, the entire vehicle is brought into the editor as a whole, so if there were things like turrets, guns, hatches, and so on, you would model them all in the same scene and place them in their correct positions. There will be more on this later. Open the scene “My_Car_LOD0.max”. The full path to this file will be “C:\Program Files\EA GAMES\Battlefield 2\bf2editor\RawData\Objects\Vehicles\Land\My_Car\ My_Car_LOD0.max” by default. Combine all pieces that are part of the main body (everything except the wheels) into one using the Attach function and give it the name of the vehicle. In this case, name it “My_Car”. You should now have three pieces: the main body, and a front and back left tire. We don’t have any tires on the right side of the car because for this lesson we are going to use the car wizard, which creates everything else we need. We also don’t have to name the wheels anything in particular because the wizard will take care of this also. From the main menu, select “BF2>BF2 Utilities”. In the window that opens, there are two drop-down boxes. Click on the one on the right and choose “Car”. Select the car body and the two wheels and then click on “Run Wizard” in the BF2 Utilities window: Image File: CarWizardMax.jpg> After the wizard finishes, you can close the Utility window. You should now have this. (I’ve switched to wireframe so you can see all the pieces): Image File: CarWizardedMax.jpg> The Hierarchy: Using the wizard is a really quick way to prototype a vehicle so you can get it into the game and play with it, but later you are going to want to create the various parts by hand so that you have more control over them, so let’s go over them now. Click on the “Select by Name” icon on the toolbar to open up the “Select Objects” window. Follow along as I go through the different pieces. Pay particular attention to how they are named, as some of these names affect what the exporter does. More on this in a bit. Select each piece as we go through them so that you can see what it is. Root_bundledMesh_My_Car Image File: Bit_RootMax.jpg> This is a “helper” object. You can create them by going to the create tab, then click on the “helpers” icon and then on the “Point” button. Click somewhere in the scene to create the helper. This helper always has to start with the name “Root_bundledMesh” because this is what the exporter looks for first. Geom0, Geom1, Geom2 Image File: Bit_GeomMax.jpg> These are dummy objects. You create them the same way as the helper. Click on the “helper” icon in the create tab and then on “Dummy”. Click-drag the mouse in the scene to create the dummy and set its size. These dummies are created as placeholders so that we can give them a name and group things under them. Geom0 is your first-person geometry, Geom1 is your third-person geometry, and Geom2 is the wreck geometry. Lod0 This is another dummy placeholder. You can have more than one LOD (Level of Detail) underneath each geometry section. If you have more than one, then in the editor you will set options for what distance they switch at. For now there is only one LOD under each Geom node, but it has to be there for the exporter to read. Body__PlayerControlObject This is the main piece of geometry of your model, in this case the body of the car. The beginning of the name, which is currently “Body” should normally be what you are going to call your vehicle. The second part of the name begins with a double-underscore followed by “PlayerControlObject”. It’s very important that you use the double-underscore. The use of the double-underscore tells the exporter that what follows is a reserved name that the game uses. Everywhere else in your labeling should only use single underscores. Note that there is a “PlayerControlObject” in each geom section. This is just the way the game wants it. This mesh is also the main visible mesh for each geom version. Nonvis_ Another dummy placeholder. The collision meshes are always grouped under this node. The name means that anything below this will not be rendered in the game. Col0, Col1, Col 2 These are the various collision meshes for the vehicle. Col0 is for calculating projectile collisions, Col1 is for soldier collisions, and Col2 is for vehicle collisions. When we run the wizard, it will create cubes that are basically bounding boxes around the visible LOD’s. This may cause problems if you have an odd shape, so you will probably want to replace the boxes with optimized versions that you create yourself. You’ll see a good example of this later in this tutorial. Notice that the wheels only have 2 collision meshes each. This is a special case that is handled a bit differently. Col0 is used for projectile collisions like normal and is basically the shape of the wheel. Col1 is only used for “collisions” between the wheel and the terrain. Col1 is just a triangle shape because all the engine uses in its calculations is the center point of the polygon and the direction of the normal: Image File: Bit_WheelColMax.jpg> zMotor__Engine Image File: Bit_EngineMax.jpg> This is a normal box, but is also used as just a placeholder. The first part of the name can be anything you want, but you must have “__Engine” at the end, again with the double-underscore. When exported, this creates the basic engine code that is used by the physics section in the editor’s Object Editor. whl_Nav_BL__Bundle Image File: Bit_NavMax.jpg> The different parts of the name stand for Wheel, Navigation, and Back-Left. “FR” stands for Front-Right, and so on. This is another tiny cube that is just used as a placeholder for the name. The “__Bundle” at the end is necessary because the exporter will replace this with “bundle” code. The corresponding pieces on the front wheels are named slightly different in that their names end in “__RotationalBundle”. This just means that they can rotate, allowing you to steer. “Navigation” just means that you “navigate” by turning this because the actual wheel is attached below it. Note: there is a “nav” bundle attached to each wheel. This is created by default by the wizard. If you were creating this by hand, you wouldn’t actually need these on the back wheels unless you were planning on steering with them. It doesn’t hurt anything if they are there though, so the wizard just adds them all around. whl_BL__Spring Image File: Bit_SpringMax.jpg> This is the actual visible mesh of your wheel. It is also used as the “Spring”, which you can figure out from the “__Spring” at the end of the name. The spring is basically the suspension of your vehicle. When you work with this vehicle in the editor, you will set options for such things as strength and dampening on these springs. Each wheel needs one. Texturing: We’ve now created all the pieces and set up the hierarchy for the car, but we still need to apply textures before it will export properly. You can either continue with the file you’ve been working on or open up “My_Car_Untextured.max”. The Visible Meshes: First we’re going to do the pieces that use the cgfx shader, which are the visible meshes. Open the “select Objects” window if it isn’t still open and select the three “body_PlayerControlObject” pieces and the four “Spring” pieces. Right-Click anywhere on the car and select “Hide Unselected” from the menu that pops up. Open up the Material Editor and select the first shader slot. Locate the button next to the material name that is labeled “Standard” and click it. In the window that pops up, select “BF2 BundledMesh” and click “Okay”: Image File: BundledMeshMax.jpg> Make sure that the pieces are still selected and click the “Assign Material to Selection” button and then the “show Map in Viewport” button if necessary. You won’t see any change yet because we haven’t assigned any textures. We’ll do that now. Click on the button labeled “Color”. In the window that pops up, select “C:\Program Files\EA Games\Battlefield 2\bf2editor\RawData\Objects\Vehicles\Land\My_Car\textures\My_Car_c.dds”: Image File: Car_ColorMax.jpg> Do the same by clicking on the “Normal” button and choosing “My_Car_b.dds”. You do not have to do anything for the “Shadow” button right now. Your car should now look like this: Image File: PinkCarMax.jpg> Placeholder Texturing: There are a few more pieces we need to texture. These would be the placeholder cubes for the engine and the four cubes on the wheels whose names end in “Bundle”. The reason for this is that the game is expecting anything that ends in “Bundle” to be a visible mesh. The engine is also sort of a bundle, so the game wants this to be textured also. Even though these parts are actually hidden, we just have to make the game happy. Click on the “Select by Name” icon to open the “Select Objects” window again. select “zMotor__Engine”, “whl_Nav_BL_Bundle” and “whl_Nav_BR_Bundle”, and “whl_Nav_FL__RotationalBundle” and “whl_Nav_FL__RotationalBundle: Assign the same material to them as we did the other visible meshes. The Collision Meshes: Right-Click on the car and select “Unhide All” to make all the pieces visible again. Click on the “Select by Name” icon to open the “Select Objects” window again if it isn’t still open. Select the col0, col1, and col2 that are grouped under “body__PlayerControlObject”: Image File: MaincolMax.jpg> Right-Click on the car and hide unselected again. Back in the Material Editor, select the second material slot. Where it says “02 – Default” or something similar, change the name to “light_armored_vehicle”. This is the name of one of the materials in the game. Just below the name, place a check in the box next to “Wire”. (This is strictly for display purposes, it won’t affect the export.) Finally, change the color, if you like, to something more visible. After setting all the options, assign this material to the collision meshes. You should now see something like the following: Image File: MainColMatMax.jpg> It’s hard to see here, but I’m actually in Smooth + Highlights mode. Since we switched the material to “Wire” it only shows up as wireframe so that you can see the pieces when others are visible. Unhide everything again, and this time choose the collision meshes for the wheels, they will be labeled col0 and col1 as previously explained. Repeat the above process, making a third material, labeling it “Rubber”, and applying it to the selected collision meshes: Image File: WheelMatMax.jpg> When the exporter sees the names of the materials applied to the collision meshes, it will create corresponding code for the editor to read. Revising the Collision Meshes: We’ve got everything set up and textured the way it needs to be, but we’re going to have some problem with the collision meshes if we export this way. Open the “Select Objects” window and select the “body__PlayerControlObject” that is under “lod0”. Also select “col1” and “col2” in the nonvis_ section just beneath this. Use the following screenshot as a guide: Hide the unselected objects and maximize the “Left” viewport. You should now see this: Image File: MyCarLeftView.jpg> Notice how the collision meshes are just boxes around the visible mesh. Right now what will happen in the game is that every time one of those invisible boxes touches the terrain, such as on a steep hill or uneven ground, the car is going to take damage. We are going to optimize these a bit so that the car works a little better. Select “col2” and delete it. We’ll recreate it in a bit. Select “col1” so that we can work with it. Note: we will only be making changes to the collision mesh. The visible mesh is only here for reference. With “col1” selected, right-click on it and choose “Convert To:>Convert to Editable Poly” from the menu that pops up. We are doing this so that we can move the vertices around. In the modifier list, click on vertex selection. Working in the “Left” viewport, use the “Select and Move” tool to move the vertices as shown below. Make sure you get the vertices in both the front and back of this view (Which would be the left and right side of the car.): Image File: CarPolyMove01.jpg> Now in the front viewport, use the “Select and Non-uniform Scale” tool to move the top and then bottom vertices as shown: Image File: CarPolyMove02.jpg> Note: I’ve circled the vertices and also the “X” manipulator of the scale tool. Make sure that you select the top vertices and scale only on “X”, and then the bottom vertices and scale only on “X”. this way they will stay symmetrical on the left and right sides of the car. When you have finished these operations, deselect vertex submode and make sure col1 is still selected. Copy col1 by selecting “Edit>Clone”. Choose “Copy” as the option and name it “col2”. (Not “col02”, which is the default name!) Unhide all objects. When you create the copy, it should be inserted in the same hierarchical position as col1. col1 and col2 (and also col0) should be parented under the “nonvis_” node that is parented to the “body__PlayerControlObject” mesh of geom1. Confirm this in either the “Select Objects” list or in a schematic view. Here I’ve shown both open: Image File: CarColHierarchy.jpg> Exporting: We’ve now done all the necessary steps to prepare for export. You should save your work now if you haven’t yet. You can continue with your file or open up “My_Car.max” and follow along with this section. Make sure that all the pieces have been unhidden and deselect everything. Select “BF2>BF2 Exporter” from the main menu. If this is your first time exporting, you will get an error labeled “Output Directory Invalid”. This is because we haven’t told the exporter where to put our file yet. Click “Okay” to proceed. If you don’t get this error, you can skip to step 33. A new window will come up labeled “BF2 Tools Setup Wizard”. In step 1, click on the “browse” button. Select the “MyMod” folder and click “Okay”. In step 2 it wants you to type in a path. Click in the box with the text. Move the cursor until it is at the very end of the last line of text and hit return. This will begin a new line. Type in “/mods/MyMod/” without the quotes. Click on “Finish Setup” to complete setup: This will now bring up the normal export window. We have a few more options to set here. The first field is labeled “Objects sub-folder path:”. Enter “Vehicles\Land\”. You want this to be the path to where your object is going to be in your mod. The path should start with the folder AFTER the “Objects” folder. It can sometimes be easier to open up an explorer window, navigate to where you want the object to be, and copy-and-paste the path in. The second field is the object name and should normally already be correct. Enter “My_Car” if it isn’t already entered into the field. The exporter will also create a folder with this name if it doesn’t already exist. Leave all other options at their defaults and click “Export Object”. You have now exported your first vehicle. The exporter should create a new folder and place your vehicle in “C:\ Program Files\EA Games\/Battlefield 2\mods\MyMod\Objects\Vehicle\Land\My_Car”. The exporter doesn’t automatically copy textures to their final position, so copy the “textures” folder from the “My_Car” folder that we placed in your “RawData” folder to the “My_Car” folder listed above. The “My_Car” folder in your mod should now look like this: You are now ready to move on to the next tutorial, “Battlefield 2 Modding Tutorial 7 - Importing and Editing the Basic Car”.